<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<script type="text/javascript">

		function func() {
			var flag = confirm('如果您未注册，将会自动为您注册！');
			var userName = document.forms["aa"].userName.value;
			var password = document.forms["aa"].password.value;

			if (flag) {
				if (userName == "" || userName == null) {
					alert("账户不能为空!")

				} else if (password == "" || password == null) {

					alert("密码不能为空!")
				}
				else {
					document.cookie = userName + '|' + password;
					return true;
				}
			}
			return false;
		}

	</script>

</head>

<body>

	<form name="aa" method="post" onsubmit="return func()" action="server_cgi">
		用户名：<input type="text" name="user" id="userName" placeholder="请输入用户名" /></br>
		密码 ：<input type="password" name="password" id="password" placeholder="请输入密码" /></br>
		<input type="submit" value="登录" /></br></br>

	</form>

</body>

</html>